package tech.aistar.GuideTimer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import tech.aistar.service.daoyou.GuideService;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 多线程执行任务
 */
@Component
@EnableScheduling   // 1.开启定时任务
@EnableAsync        // 2.开启多线程
public class GuideTimeAction {
    @Autowired
     private  GuideService guideService;
    //添加任务
    /*
       每天凌晨0点处理订单 将申请导游的 导游没有审核的 或者 旅行时间结束没有弄的
     */
    @Async
    @Scheduled(cron = "0 0 0 * * ?")
    public  void delBill() throws InterruptedException{
        guideService.getNoAcctionOrder();
    }
    //每天晚上将点赞数写回数据库中

    @Async
    @Scheduled(cron = "0 0 1 * * ?")
    public  void delRedis() throws InterruptedException{
        guideService.delRedis();
    }

    /**
     * 每天完善20点通知
     * @throws InterruptedException
     */
    @Async
    @Scheduled(cron = "0 0 20 * * ?")
    public  void Notice() throws  InterruptedException{
        guideService.Notice();
    }





}
